package com.demo.phone;

import com.alibaba.fastjson.JSON;
import com.demo.phone.req.BaseRequest;
import com.demo.utils.ParseMD5;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : YU.TAN
 * @date : 2021/10/26 17:45
 */
public class TestA {
    public static void main(String[] args) {
        RequestABO requestABO=new RequestABO();
//        requestABO.setDealerId("12314");
//        requestABO.setMediaLeadsId("352");
//        requestABO.setMediaType("3462");
        requestABO.setOrderId("861352066");

        String string = JSON.toJSONString(requestABO);
        Map<String,RequestABO> map=new HashMap(16);
//        map.put("param",requestABO);
        map.put("param",requestABO);

        String s1 = JSON.toJSONString(map);
        System.out.println(s1);
        long time = System.currentTimeMillis() / 1000;
        BaseRequest<Object> build = BaseRequest.builder()
                .appKey("smart_marketing")
                .data(s1)
//                .timeStamp(String.valueOf(time))
                .timeStamp("1634353847")
                .t(requestABO)
                .build();

        String str = getStr(build);
        System.out.println(str);

        String s = ParseMD5.parseStrToMd5U32(str);
        System.out.println(s);

//        String result="%sappKey=%s%s";
//        String format = String.format(result, "A", "C", "D");
//        System.out.println(format);



//        BaseRequest.builder().appKey("smart_marketing")
//                .



    }

    public static String getStr(BaseRequest baseRequest){
        String result="%sappKey=%sparam=%stimestamp=%s%s";
//        String result="'%s'appKey='%s'param='%s'timestamp='%s''%s'";
        return String.format(result,"F4AA729C6F820C6742C9C57FC435B967",baseRequest.getAppKey(),baseRequest.getData(),baseRequest.getTimeStamp(),"F4AA729C6F820C6742C9C57FC435B967");
    }

}
